package com.bnq.logc.action

import com.bnq.logc.Logc
import com.bnq.logc.LogcLevel
import com.bnq.logc.utils.DateUtil

class SendAction(
    level:Int,
    tag:String,
    log:String,
    localTime:Long,
    threadName:String,
    isMainThread:Boolean,
    val map:Map<String,Any?>?,
) : WriteAction(level, tag, log, localTime, threadName, isMainThread) {

    companion object{
        fun createSendAction(action: WriteAction):SendAction{
            return SendAction(action.level,action.tag,action.log,action.localTime,action.threadName,action.isMainThread,null)
        }
    }

    fun toMap():Map<String,Any?>{
        val map = mutableMapOf<String,Any?>()
        map["logLevel"] = LogcLevel.getLevelName(level)
        map["tag"] = tag
        map["content"] = log
        map["createTime"] = localTime//DateUtil.formatDateTime(localTime)
        if(this.map != null){
            map.putAll(this.map)
        }
        return map
    }

}